package com.yanliang.SqlSession;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

/**
 * 定义数据库的crud操作
 *
 * @Author : yanliang
 * @Data : 3/25/2020 6:55 PM
 */
public interface SqlSession {

    /**
     * 查询所有
     * @param statementId   params可选，用于模糊查询多个
     * @return list
     * @exception/throws
     */
    public <E> List<E> selectList(String statementId, Object... params) throws IllegalAccessException, IntrospectionException, InstantiationException, SQLException, InvocationTargetException, NoSuchFieldException;

    /**
     * 按条件查询
     * @param statementId    params：查询条件
     * @return T
     * @exception/throws
     */
    public <T> T selectOne(String statementId, Object... params) throws IllegalAccessException, IntrospectionException, InstantiationException, SQLException, InvocationTargetException, NoSuchFieldException;


    /**
     * insert or udpate or delete
     * @param statementId
     * @param params
     * @return
     */
    public int update(String statementId, Object... params) throws NoSuchFieldException, IllegalAccessException, SQLException;

    /**
     * 为Dao接口生成代理实现类
     * @param mapperClass
     * @param <T>
     * @return
     */
    public <T> T getMapper(Class<?> mapperClass);
}
